package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * @author zhouwq
 * @date 2022/4/14 15:53
 */
@Getter
public enum PublicSeasSeniorTabEnum {

    PUBLIC_GROUP_RULE_SET("enum.publicSeas.name.public_group_rule_set", 1),
    PUBLIC_BACK_RULE_SET("enum.publicSeas.name.public_back_rule_set", 2),
    PUBLIC_TRANSFER_RULE_SET("enum.publicSeas.name.public_transfer_rule_set", 3),
    PUBLIC_DISTRIBUTION_RULE_SET("enum.publicSeas.name.public_distribution_rule_set", 4),
    PUBLIC_OTHER_RULE_SET("enum.publicSeas.name.public_other_rule_set", 5),
    UNKNOWN("enum.xbbRefType.name.unknown",404),
    ;


    private String name;

    private Integer code;

    PublicSeasSeniorTabEnum(String name, Integer code){
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static PublicSeasSeniorTabEnum getByCode(Integer code) {
        for (PublicSeasSeniorTabEnum cacheCode : values()) {
            if (Objects.equals(code, cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
}
